﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="adminProduct.aspx.cs" Inherits="Admin_adminProduct"  EnableViewState="false"   EnableViewStateMac="false"  %>

<%@ Register Src="adminfoot.ascx" TagName="adminfoot" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="X-UA-Compatible" content="IE=7" > 
<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">
    <title>产品管理</title>
    <link rel="stylesheet" href="imgs/admin.css" type="text/css" media="all" />
    <script type="text/javascript" src="../DotNet_net/js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="imgs/GetAjax.js"></script>
    <script type="text/javascript" src="../DotNet_net/js/common.js"></script>
</head>
<body onload="$('#loading').hide()">
<form id="form1" runat="server">
<div class="container" id="cpcontainer">
<div id="loading" style="display:block">   
        <div class="loading-indicator">   
            页面正在加载中...   
        </div>   
</div>
<table class="tb">
<tr class="thead"><th colspan="15">
    数据管理(产品数据:如果您推荐了产品又同时把产品标识为最新和首页展示，那么这个产品有可能重复显示)</th></tr>	
<tr><td align="left" colspan="10">  

关键字<input  name="keyword" type="text" id="keyword" size="20" value="">
<%=ProductClassDp("pclassType")%>
<input type="button" name="selectBtn"  value="查 询..." class="btn" onclick='SelectKey("?")'/>&nbsp;

</td>
</tr>
  <tr bgcolor="#f5fafe">
	<td style="width: 5%">ID<a href="#"><img src="imgs/minus.gif" title="按ID排序" /></a></td>
	<td style="width: 15%"> 产品名称</td>
	<td style="width:10%">
        产品型号</td>
	<td style="width: 10%">
        关联标记</td>
    <td style="width: 10%">数据类别</td>
	<td style="width: 5%">
        排序
    </td>
	<td style="width: 5%">
        浏览次数</td>
	<td style="width: 40%" align="left">
        (推荐,最新,首页展示,屏蔽,编辑,删除,属性)操作</td>
  </tr>
  
      <asp:Repeater ID="Repeater1" runat="server">
      <ItemTemplate>
<tr bgcolor="#f5fafe" lang='<%=num++ %>'>
	<td ><input type="checkbox" value='<%#((System.Data.DataRowView)Container.DataItem)[0]%>' name="m_id"   class="checkbox" /><%#((System.Data.DataRowView)Container.DataItem)[0]%></td>
	<td style="width: 179px"><a href='../zh/<%#DotNet.Business.UrlTrans.TransUrl("productDetail", Eval("productID").ToString(), "", "", "", "", "")%>' target="_blank" ><%#Eval("productname") %></a><span id="state1"><a title='<%#Eval("productId") %>' href="#msg" onclick="GivePower(this,this.title)"><img src="imgs/icon_01.gif"   style="cursor:pointer"  /></a></span></td>
    <td><%#Eval("productModel") %></td>	
	<td><input name='mark<%#Eval("productId") %>' size="3" type="text" value='<%#Eval("RelationMark") %>' /></td>
	<td>
        <span style="color: #2366a8"><%#chooseProductByClassId(Convert.ToInt32(Eval("pclassid")))%></span></td>
	<td>
        <input name='psort<%#Eval("productId") %>' size="3" type="text"   value='<%#Eval("pSort") %>'/></td>
	<td><span><span style='color:red;font-size:10px'><input name='pview<%#Eval("productId") %>' size="3" type="text" value='<%#Eval("views") %>' /></span></span></td>   
	<td>
	  <a href ="tabAdmin.aspx?productid=<%#Eval("productID") %>">Tab</a>
	  <input id="Button1" type="button" value="添加属性" class="btn" title="<%#Eval("productId") %>" onclick="javascript:location.href='AddProductAttribute.aspx?action=load&pid='+this.title"/>
	  <input id="Button6" type="button" value="属性" class="btn" title="<%#Eval("productId") %>" onclick="javascript:location.href='EditProductAttribute.aspx?action=load&pid='+this.title"/>  
	  <input id="Button5" type="button" value="编辑" class='btn' title='<%#Eval("productId") %>' onclick="javascript:location.href='EditProduct.aspx?productId='+this.title"/>

	  <input id="btnDel" type="button" value="删除" class='btn' title='<%#Eval("productId") %>' onclick="if(confirm('确定要删除吗')){$('#loading').show();ajax_get('?action=delAll&id='+this.title+$('#HiddenUrl').attr('value'),'',function(msg){$('#cpcontainer').empty().append(msg);$('#loading').hide()});}else{return false}"/>
	  <input id='bast<%#Eval("productId") %>' type="button" value='<%#Convert.ToInt32(Eval("isbast"))==0?"推荐":"已推荐" %>' class='btn' name='isBast<%#Eval("productId") %>' title='<%#Eval("isBast") %>' onclick='doGetIsBool("",this,"bast","推荐")'  lang='<%#Eval("productId") %>'/>
	  <input id='new<%#Eval("productId") %>' type="button" value='<%#Convert.ToInt32(Eval("IsNew"))==0?"最新":"已最新" %>' class='btn' name='IsNew<%#Eval("productId") %>' title='<%#Eval("IsNew") %>' onclick='doGetIsBool("",this,"new","最新")'  lang='<%#Eval("productId") %>' />
	  <input id='index<%#Eval("productId") %>' type="button" value='<%#Convert.ToInt32(Eval("isIndex"))==0?"首页推荐":"已首页推荐" %>' class='btn' name='isIndex<%#Eval("productId") %>' title='<%#Eval("isIndex") %>' onclick='doGetIsBool("",this,"index","首页推荐")'  lang='<%#Eval("productId") %>'/>
	  <input id='can<%#Eval("productId") %>' type="button" value='<%#Convert.ToInt32(Eval("isCan"))==0?"屏蔽":"已屏蔽" %>' class='btn' name='isCan<%#Eval("productId") %>' title='<%#Eval("isCan") %>' onclick='doGetIsBool("",this,"can","屏蔽")'  lang='<%#Eval("productId") %>'/>
	</td>
  </tr>
        
      </ItemTemplate>
      </asp:Repeater>

<tr><td colspan="11"><div class="cuspages"><div class="pages" id="pro" runat="server"><div style="width:90%; float:left;">全选<input type="checkbox" name="chkall" id="chkall" class="checkbox" onclick="checkAll(this.checked,'m_id')" />反选<input type="checkbox" name="chkothers" id="chkothers" class="checkbox" onclick="checkOthers('m_id')" />
<input type="button" value="批量修改" class="btn"  onclick="doPostEdit('','m_id')" />
<%=ProductClassDp("pctp")%>
<input type="button"   value="批量移动" class="btn" onclick="doPostMove('','m_id')"/>&nbsp;</div>
<div style="float:right; width:10%; text-align: center;"><input type="button" value="批量删除" onclick="doPostDeletes('','m_id')" class="btn" style=" color:Red;" /> &nbsp;</div>
    </div></div></td>
</tr>

<tr><td colspan="11"><div class="cuspages"><div id="a" class="pages">
 <%htmlPaging();%></div></div></td>
</tr>
</table>
<%=input%>
  <uc1:adminfoot ID="Adminfoot1" runat="server" />
</div>
<%--删除,移动,修改start--%>
<script type="text/javascript" >

    function  doPostDeletes(url,sname)
    {    
                
        var ids=getIDList(sname);
        if(ids!="")
        {
            if((confirm("确定要删除这些记录?"))==true)
            {
                $("#loading").show();
                url=convertURL(url+"?action=delAll&id="+ids+$("#HiddenUrl").attr("value"));
                $("#loading").show();
                ajax_get(url,'',function(msg)
                {                   
                   $("#cpcontainer").empty().append(msg);
                   $("#loading").hide();
                });
	        }
	    }
	    else
	    {
	        alert("您还没有选择要删除的项");	        
	        return false;
	    }
    }
    
    function  doPostEdit(url,sname)
    {    
     
        var ids=getIDList(sname);
        var Param='';
        if(ids!="")
        {
            if((confirm("确定要批量修改这些记录?"))==true)
            {   $("#loading").show();    
                  url=url+"?action=editAll&id="+ids+$("#HiddenUrl").attr("value"); 
                  for(var i=0;i<=ids.split(',').length-1;i++)
                  { 
                     var id=ids.split(',')[i];
                     Param+= "&psort"+id+"="+$("input[name='psort"+id+"']").attr("value")+
                             "&pview"+id+"="+$("input[name='pview"+id+"']").attr("value")+
                             "&isBast"+id+"="+$("input[name='isBast"+id+"']").attr("title")+
                             "&IsNew"+id+"="+$("input[name='IsNew"+id+"']").attr("title")+
                             "&isIndex"+id+"="+$("input[name='isIndex"+id+"']").attr("title")+
                             "&isCan"+id+"="+$("input[name='isCan"+id+"']").attr("title")+
                             "&mark"+id+"="+$("input[name='mark"+id+"']").attr("value");                            
                  }
                  ajax_post(url,Param,function(msg,date)
                  {
                        $("#cpcontainer").empty().append(msg);
                        $("#loading").hide();                  
                  });
	        }
	    }
	    else
	    {
	        alert("您还没有选择要修改的项");	    
	        return;
	    }
    }
    
    function doPostMove(url,sname)
    {
     
        var ids=getIDList(sname);
        if(ids!="")
        {
            var yidong="";
            var Param="";
            yidong=$("#pro #pctp option:selected").attr("value");
            if((confirm("确定要移动这些记录?"))==true)
            {   $("#loading").show();
                url=convertURL(url+"?action=MoveAll&id="+yidong+"&pid="+ids+$("#HiddenUrl").attr("value"));
                 $("#loading").show();
                ajax_get(url,'',function(msg)
                {
                     $("#cpcontainer").empty().append(msg);
                     $("#loading").hide();
                    
                });
	        }
	    }
	    else
	    {
	        alert("您还没有选择移动项");	 
	        return false;
	    }
    } 
    
   function SelectKey(url)
   {
      $("#loading").show();
      url=convertURL("?key="+escape($("#keyword").attr("value"))+"&ClassId="+$("#pclassType option:selected").attr("value")+"&CurrentIndex=1");
       $("#loading").show();
      ajax_get(url,'',function(msg)
      {
        $("#cpcontainer").empty().append(msg);
        $("#loading").hide();
      });
       
   }
   
  function doGetIsBool(url,em,type,name)
  {
      url=convertURL("?action="+type+"&bo="+em.title+"&id="+em.lang+$("#HiddenUrl").attr("value"));
      $("#loading").show();
      ajax_get(url,'',function(msg)
      {
        if(msg==name)
        {
         
            $("#"+em.id).attr("value",name);
            $("#"+em.id).attr("title","false");
            $("#loading").hide();
        }
        else
        {
             $("#"+em.id).attr("value","已"+name);
              $("#"+em.id).attr("title","true");
             if(msg=="已屏蔽")
             {
                location.href=location.href;
             }
             $("#loading").hide();
        }
      });
  }
 </script>
<%--删除,移动,修改end--%>
    <script type="text/javascript" >
    function changePage(name)
    {

    }
    </script>
</form>
</body>
<script type="text/javascript">
function GivePower(tg,title)
{
   var  el=$(tg).prev()[0];
   _1=el;openWindow2(20,420,400,0);
	var msgDiv=document.getElementById("msg");
	var _t = tg.offsetTop;
    var _l = tg.offsetLeft;
    while (tg = tg.offsetParent){_t+=tg.offsetTop; _l+=tg.offsetLeft;}
    msgDiv.style.cssText+="border:1px solid #55BBFF;background: #C1E7FF;padding:1px 0px 1px 1px;height: auto;"
	msgDiv.style.top = (_t-1)+"px";
    msgDiv.style.left = (_l-1)+"px";
	msgDiv.innerHTML='<button type="button" class="btn" style="margin:0 6px 0 0;height:23px;float:right;padding:0;" onclick="closeWin()">关闭</button><iframe src="FileDownLoad/selectRole.aspx?type=0&productId='+title+'" scrolling="no" topmargin="0"  height:auto;overflow:auto;  marginwidth="0" marginheight="0" frameborder="0" align="center"  onload="this.height=this.contentWindow.document.documentElement.scrollHeight"></iframe>';
}
</script>  
</html>

